/**
 *  @author Ion Morozan
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.dddforandroid.design;

import android.accounts.Account;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

import com.dddforandroid.database.R;

public class CreateTabsActivity extends TabActivity {
	/**
	 * Called when the activity is first created
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_app);

		Resources res = getResources(); // Resource object to get Drawables
		TabHost tabHost = getTabHost(); // The activity TabHost
		TabHost.TabSpec spec; // Resusable TabSpec for each tab
		Intent intent; // Reusable Intent for each tab

		Account account = (Account) getIntent().getExtras().get("account");
		// Create an Intent to launch an Activity for the tab (to be reused)
		intent = new Intent().setClass(this, CurrentTasksActivity.class);
		intent.putExtra("account", account);

		// Initialize a TabSpec for each tab and add it to the TabHost
		spec = tabHost
				.newTabSpec("tasks")
				.setIndicator("Tasks",
						res.getDrawable(R.drawable.ic_tab_current_tasks))
				.setContent(intent);
		tabHost.addTab(spec);

		// Do the same for the other tabs
		intent = new Intent().setClass(this, AddTaskActivity.class);
		spec = tabHost
				.newTabSpec("addTask")
				.setIndicator("Add Task",
						res.getDrawable(R.drawable.ic_tab_add_task))
				.setContent(intent);
		tabHost.addTab(spec);

	}
}
